<template>
  <div class="main" @mousewheel.prevent>
    <div class="head">
      <div class="ift-back" @click="returns"></div>
      <h1>登录</h1>
      <div></div>
    </div>
    <div class="logo">
      <img src="https://m.kanman.com/static/images/login/logo.png" alt="" />
    </div>
    <div class="input">
      <div>
        <span class="ift-user"></span>
        <input
          type="text"
          placeholder="请输入星球账号、手机号码、邮箱"
          v-model="user"
        /><span></span>
      </div>
      <div>
        <span class="ift-lock"></span>
        <input
          :type="flag == false ? 'text' : 'password'"
          placeholder="请输入密码"
          v-model="password"
        />
        <span @click="flags">
          <i v-show="flag" class="ift-eye-close"></i>
          <i v-show="!flag" class="ift-eye-open"></i>
        </span>
      </div>
      <p class="sign" @click="sign">登录</p>
      <p class="Third-party">使用第三方账号登录</p>
      <div class="Login-mode">
        <div><i class="ift-sina"></i></div>
        <div><i class="ift-qq"></i></div>
      </div>
      <p class="agreement">
        登录代表你已阅读并同意
        <a href="https://m.kanman.com/about/409276.html">《看漫画用户协议》</a>
      </p>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      user: "",
      password: "",
      flag: true,
    };
  },
  methods: {
    flags() {
      this.flag = !this.flag;
    },
    returns() {
      this.$router.push("/homePage");
    },
    sign() {
      let usr = /^\d{6,16}$/;
      if (!usr.test(this.user)) {
        Toast("账号密码错误");
        return;
      }
      localStorage.setItem("user", this.user);
      let pass = /^[A-Za-z0-9]{6,16}$/;
      if (!pass.test(this.password)) {
        Toast("账号密码错误");
        return;
      }
      localStorage.setItem("password", this.password);
      this.$router.push("/my")
    },
  },
};
</script>

<style lang="less">
.main {
  .head {
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    .cancel {
      font-size: 14px;
      color: black;
    }
    div {
      width: 60px;
      font-size: 20px;
      color: #fc6976;
      padding: 0 10px;
      &:nth-child(3) {
        font-size: 12px;
        color: black;
        span {
          color: #fc6976;
        }
      }
    }
    h1 {
      flex: 1;
      font-size: 18px;
      font-weight: 500;
      text-align: center;
    }
  }
  .logo {
    width: 24%;
    margin: 40% auto 10%;
    img {
      width: 100%;
    }
  }
  .input {
    width: 90%;
    margin: 0 auto;
    div {
      display: flex;
      justify-content: space-between;
      text-align: center;
      border-bottom: 1px solid #f5f5f5;
      padding: 1% 0;
      input {
        flex: 1;
        border: none;
        font-size: 12px;
      }
      span {
        display: block;
        width: 10%;
        font-size: 24px;
        color: #fc6976;
        position: relative;
        i {
          position: absolute;
          font-size: 18px;
        }
      }
    }
    p {
      padding: 3% 0;
      width: 100%;
      font-size: 14px;
      text-align: center;
      color: #fc6976;
    }
    .forget {
      margin: 8% 0;
      text-align: right;
      padding: 0;
    }
    .sign {
      margin-top: 40px;
      border-radius: 3px;
      color: white;
      background-color: #fc6976;
    }
    .Third-party {
      color: #999;
      font-size: 12px;
      opacity: 0.5;
    }
    .Login-mode {
      width: 50%;
      margin: 0 auto;
      text-align: center;
      display: flex;
      border: none;
      div {
        border: none;
        width: 50%;
        i {
          margin: 0 auto;
          width: 50px;
          height: 50px;
          line-height: 50px;
          border: 1px solid #fc6976;
          border-radius: 50%;
          font-size: 24px;
          color: #fc6976;
        }
      }
    }
    .agreement {
      font-size: 12px;
    }
  }
}
</style>